package leetcode5;

import java.util.ArrayList;
import java.util.List;

/*
*
* 189. 轮转数组*/
public class test13 {
    public void rotate(int[] nums, int k) {
        k %= nums.length;
        reverse(nums,0,nums.length - 1);
        reverse(nums,0,k-1);
        reverse(nums,k,nums.length - 1);
        for(int i = 0;i < nums.length;i++){
            System.out.print(nums[i]);
        }
    }
    public void reverse(int[] nums,int l,int r){
        while(l < r){
            int temp = nums[l];
            nums[l] = nums[r];
            nums[r] = temp;
            l++;
            r--;
        }
    }
}
